package blackstar.agent.web;

import java.io.IOException;
import java.util.Map;

import javax.management.remote.JMXServiceURL;

import mx4j.tools.remote.http.WebContainer;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author RayWoo (ayufox@gmail.com)
 * 
 */
public class AgentWebContainer implements WebContainer
{
	private final static Log LOGGER = LogFactory
			.getLog(AgentWebContainer.class);

	private static JettyWebService INSTANCE;

	public static void setInstance(JettyWebService instance)
	{
		INSTANCE = instance;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mx4j.tools.remote.http.WebContainer#start(javax.management.remote.JMXServiceURL,
	 *      java.util.Map)
	 */
	public void start(JMXServiceURL jmxserviceurl, Map map) throws IOException
	{
		LOGGER.info("start : " + jmxserviceurl);
		INSTANCE.start(jmxserviceurl, map);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mx4j.tools.remote.http.WebContainer#stop()
	 */
	public void stop() throws IOException
	{
		LOGGER.info("stop");
		INSTANCE.stop();
	}

	public void deploy(String servletClassName, JMXServiceURL url,
			Map environment) throws IOException
	{
		INSTANCE.deploy(servletClassName, url, environment);
	}

	public void undeploy(String servletName, JMXServiceURL url, Map environment)
	{
		INSTANCE.undeploy(servletName, url, environment);
	}
}
